<template>
    <div>
        <van-field v-model='form.username' label='用户名' placeholder='请输入用户名'/>
        <van-field v-model='form.password' label='密码' placeholder='请输入密码'/>
          <van-button color="linear-gradient(to right, #7232dd, #ffffff)" @click="login" style="width:200px">
                登录
          </van-button>
     
    </div>
</template>

<script>
    export default {
        data(){
            return{
                form:{}
            }
        },
        methods:{
            login(){
                //调用接口登录
                this.$axios.post('auser/login',this.form)
                .then(res=>{
                    //根据返回结果进行操作,code==200,存userid,跳转到个人中心
                    if(res.data.code==200){
                        localStorage.setItem('userid',res.data.userid)
                        localStorage.setItem('username',res.data.username)
                        localStorage.setItem('sign',res.data.sign)
                        alert('登录成功')
                        this.$router.push({'path':'/uinfo'})
                        
                    }
                })
            }
        },
    }
</script>

<style scoped>

</style>